package com.zdxlz.fcmp.common.mybatis.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description：用户信息表【用户类型】枚举类
 * @Author： aman
 * @Date： 2025/2/8 11:12
 */
@Getter
@AllArgsConstructor
public enum UserTypeEnum {
    SUPPER(1, "超级管理员"),
    TENANT(2, "租户管理员"),
    USER(3, "普通用户"),
    ;
    @EnumValue
    private final Integer code;
    private final String name;

    public static UserTypeEnum getByCode(Integer code) {
        for (UserTypeEnum algorithmEnum : UserTypeEnum.values()) {
            if (algorithmEnum.getCode() == code) {
                return algorithmEnum;
            }
        }
        return null;
    }

    @JsonValue
    public int getCode() {
        return code;
    }
}
